/* @(#)DecKanGlDecoratorCanvasLocation.java
** 
** Copyright (C) 2001-2011 by Steven D. Stamps
**
**             Trademarks & Copyrights
** Flywheel Management Science(TM) and FlywheelMS(TM) are exclusive
** trademarks of Steven D. Stamps and may only be used freely for
** the purpose of identifying the unforked version of this software.
** Subsequent forks (if any) may not use these trademarks.  All other
** rights are reserved.
**
** DecKanGL (Decorated Kanban Glyph Language) and TribKn (Tribal Knowledge)
** are also exclusive trademarks of Steven D. Stamps.  These may be used
** freely within the unforked FlywheelMS application and documentation.
** All other rights are reserved.
**
** Trademark information is available at
** <http://www.flywheelms.org/trademarks>
**
** Flywheel Management Science(TM) is a copyrighted body of management
** metaphors, governance processes, and leadership techniques that is
** owned by Steven D. Stamps.  These copyrighted materials may be freely
** used, without alteration, by the community (users and developers)
** surrounding this GPL3-licensed software.  Additional copyright
** information is available at <http://www.flywheelms.org/copyrights>
**
**              GPL3 Software License
** This program is free software: you can use it, redistribute it and/or
** modify it under the terms of the GNU General Public License, version 3,
** as published by the Free Software Foundation. This program is distributed
** in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
** even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
** PURPOSE.  See the GNU General Public License for more details. You should
** have received a copy of the GNU General Public License, in a file named
** COPYING, along with this program.  If you cannot find your copy, see
** <http://www.gnu.org/licenses/gpl-3.0.html>.
*/
package com.fmscorp.deckangl.core;

import java.util.HashMap;

/**
 * @author sstamps
 */
public enum DecKanGlDecoratorCanvasLocation {
	
	/* There are 10 possible decorator locations in a DecKanGL Glyph.
	 * Many applications do not utilize all decorator locations.
	 */
	bottom_zone_LEFT(
			"Bottom Zone - Left",
			DecKanGlDecoratorCanvasZone.BOTTOM_ZONE,
			DecKanGlGlyphDictionary.getInstance().getWidthBottomDecorators(),
			DecKanGlGlyphDictionary.getInstance().getHeightBottomZone(),
			new String[] {
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_LEFT_BLUE,
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_LEFT_DISABLED,
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_LEFT_GRAY,
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_LEFT_GREEN,
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_LEFT_MAGENTA,
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_LEFT_ORANGE,
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_LEFT_RED,
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_LEFT_YELLOW,
			    DecKanGlImageManager.icon_path_DECORATOR_TRANSPARENT }
			),
	bottom_zone_RIGHT(
			"Bottom Zone - Right",
			DecKanGlDecoratorCanvasZone.BOTTOM_ZONE,
			DecKanGlGlyphDictionary.getInstance().getWidthBottomDecorators(),
			DecKanGlGlyphDictionary.getInstance().getHeightBottomZone(),
			new String[] {
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_BLUE,
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_DISABLED,
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_GRAY,
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_GREEN,
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_MAGENTA,
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_ORANGE,
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_RED,
			    DecKanGlImageManager.icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_YELLOW,
			    DecKanGlImageManager.icon_path_DECORATOR_TRANSPARENT } ),
	left_zone_BOTTOM(
			"Left Zone - Bottom",
			DecKanGlDecoratorCanvasZone.LEFT_ZONE,
			DecKanGlGlyphDictionary.getInstance().getWidthLeftZone(),
			DecKanGlGlyphDictionary.getInstance().getHeightLeftCornerDecorators(),
			new String[] {
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_BOTTOM_BLUE,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_BOTTOM_DISABLED,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_BOTTOM_GRAY,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_BOTTOM_GREEN,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_BOTTOM_MAGENTA,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_BOTTOM_ORANGE,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_BOTTOM_RED,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_BOTTOM_YELLOW,
			    DecKanGlImageManager.icon_path_DECORATOR_TRANSPARENT } ),
	left_zone_MIDDLE(
			"Left Zone - Middle",
			DecKanGlDecoratorCanvasZone.LEFT_ZONE,
			DecKanGlGlyphDictionary.getInstance().getWidthLeftZone(),
			DecKanGlGlyphDictionary.getInstance().getHeightLeftMiddleDecorators(),
			new String[] {
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_MIDDLE_BLUE,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_MIDDLE_DISABLED,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_MIDDLE_GRAY,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_MIDDLE_GREEN,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_MIDDLE_MAGENTA,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_MIDDLE_ORANGE,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_MIDDLE_RED,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_MIDDLE_YELLOW,
			    DecKanGlImageManager.icon_path_DECORATOR_TRANSPARENT } ),
	left_zone_TOP(
			"Left Zone - Top",
			DecKanGlDecoratorCanvasZone.LEFT_ZONE,
			DecKanGlGlyphDictionary.getInstance().getWidthLeftZone(),
			DecKanGlGlyphDictionary.getInstance().getHeightLeftCornerDecorators(),
			new String[] {
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_TOP_BLUE,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_TOP_DISABLED,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_TOP_GRAY,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_TOP_GREEN,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_TOP_MAGENTA,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_TOP_ORANGE,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_TOP_RED,
			    DecKanGlImageManager.icon_path_DECORATOR_LEFT_ZONE_TOP_YELLOW,
			    DecKanGlImageManager.icon_path_DECORATOR_TRANSPARENT } ),
	right_zone_BOTTOM(
			"Right Zone - Bottom",
			DecKanGlDecoratorCanvasZone.RIGHT_ZONE,
			DecKanGlGlyphDictionary.getInstance().getWidthRightZone(),
			DecKanGlGlyphDictionary.getInstance().getHeightRightCornerDecorators(),
			new String[] {
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_BLUE,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_DISABLED,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_GRAY,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_GREEN,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_MAGENTA,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_ORANGE,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_RED,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_YELLOW,
			    DecKanGlImageManager.icon_path_DECORATOR_TRANSPARENT } ),
	right_zone_MIDDLE(
			"Right Zone - Middle",
			DecKanGlDecoratorCanvasZone.RIGHT_ZONE,
			DecKanGlGlyphDictionary.getInstance().getWidthRightZone(),
			DecKanGlGlyphDictionary.getInstance().getHeightRightMiddleDecorators(),
			new String[] {
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_BLUE,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_DISABLED,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_GRAY,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_GREEN,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_MAGENTA,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_ORANGE,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_RED,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_YELLOW,
			    DecKanGlImageManager.icon_path_DECORATOR_TRANSPARENT } ),
	right_zone_TOP(
			"Right Zone - Top",
			DecKanGlDecoratorCanvasZone.RIGHT_ZONE,
			DecKanGlGlyphDictionary.getInstance().getWidthRightZone(),
			DecKanGlGlyphDictionary.getInstance().getHeightRightCornerDecorators(),
			new String[] {
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_TOP_BLUE,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_TOP_DISABLED,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_TOP_GRAY,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_TOP_GREEN,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_TOP_MAGENTA,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_TOP_ORANGE,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_TOP_RED,
			    DecKanGlImageManager.icon_path_DECORATOR_RIGHT_ZONE_TOP_YELLOW,
			    DecKanGlImageManager.icon_path_DECORATOR_TRANSPARENT } ),
	top_zone_LEFT(
			"Top Zone - Left",
			DecKanGlDecoratorCanvasZone.TOP_ZONE,
			DecKanGlGlyphDictionary.getInstance().getWidthTopDecorators(),
			DecKanGlGlyphDictionary.getInstance().getHeightTopZone(),
			new String[] {
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_LEFT_BLUE,
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_LEFT_DISABLED,
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_LEFT_GRAY,
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_LEFT_GREEN,
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_LEFT_MAGENTA,
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_LEFT_ORANGE,
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_LEFT_RED,
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_LEFT_YELLOW,
			    DecKanGlImageManager.icon_path_DECORATOR_TRANSPARENT } ),
	top_zone_RIGHT(
			"Top Zone - Right",
			DecKanGlDecoratorCanvasZone.TOP_ZONE,
			DecKanGlGlyphDictionary.getInstance().getWidthTopDecorators(),
			DecKanGlGlyphDictionary.getInstance().getHeightTopZone(),
			new String[] {
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_RIGHT_BLUE,
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_RIGHT_DISABLED,
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_RIGHT_GRAY,
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_RIGHT_GREEN,
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_RIGHT_MAGENTA,
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_RIGHT_ORANGE,
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_RIGHT_RED,
			    DecKanGlImageManager.icon_path_DECORATOR_TOP_ZONE_RIGHT_YELLOW,
			    DecKanGlImageManager.icon_path_DECORATOR_TRANSPARENT } );

	private String name = null;
	private DecKanGlDecoratorCanvasZone decKanGlDecoratorCanvasZone;
	private HashMap<DecKanGlDecoratorColor, String> imageIconPathMap = new HashMap<DecKanGlDecoratorColor, String>();
	private int decoratorWidth;
	private int decoratorHeight;
	
	private DecKanGlDecoratorCanvasLocation(
			String aName,
			DecKanGlDecoratorCanvasZone aDecKanGlDecoratorCanvasZone,
			int aDecoratorWidth,
			int aDecoratorHeight,
			String[] anImageIconPathArray ) {
		this.name = aName;
		this.decKanGlDecoratorCanvasZone = aDecKanGlDecoratorCanvasZone;
		this.initializeImageMap(anImageIconPathArray);
		this.decoratorWidth = aDecoratorWidth;
		this.decoratorHeight = aDecoratorHeight;
	}
	
	private void initializeImageMap(String[] anImageIconPathArray) {
		imageIconPathMap.put(DecKanGlDecoratorColor.BLUE, anImageIconPathArray[0]);
		imageIconPathMap.put(DecKanGlDecoratorColor.DISABLED, anImageIconPathArray[1]);
		imageIconPathMap.put(DecKanGlDecoratorColor.GRAY, anImageIconPathArray[2]);
		imageIconPathMap.put(DecKanGlDecoratorColor.GREEN, anImageIconPathArray[3]);
		imageIconPathMap.put(DecKanGlDecoratorColor.MAGENTA, anImageIconPathArray[4]);
		imageIconPathMap.put(DecKanGlDecoratorColor.ORANGE, anImageIconPathArray[5]);
		imageIconPathMap.put(DecKanGlDecoratorColor.RED, anImageIconPathArray[6]);
		imageIconPathMap.put(DecKanGlDecoratorColor.YELLOW, anImageIconPathArray[7]);
		imageIconPathMap.put(DecKanGlDecoratorColor.TRANSPARENT, anImageIconPathArray[8]);
	}

	public String toString() {
		return this.name;
	}
	
	public String getName() {
		return this.name;
	}
	
	public DecKanGlDecoratorCanvasZone getCanvasZone() {
		return this.decKanGlDecoratorCanvasZone;
	}
	
	public String getImageIconPathForColor(DecKanGlDecoratorColor aDecoratorColor) {
		return imageIconPathMap.get(aDecoratorColor);
	}

	public HashMap<DecKanGlDecoratorColor, String> getImageIconPathMap() {
		return imageIconPathMap;
	}

	public int getDecoratorWidth() {
		return decoratorWidth;
	}

	public int getDecoratorHeight() {
		return decoratorHeight;
	}

	public int getCanvasPositionX(DecKanGlGlyph aDecKanGlGlyph) {
		if (this.getCanvasZone() == DecKanGlDecoratorCanvasZone.LEFT_ZONE) {
			return aDecKanGlGlyph.getCanvas().getMarginLeft();
		}
		if (this.getCanvasZone() == DecKanGlDecoratorCanvasZone.RIGHT_ZONE) {
			return aDecKanGlGlyph.getCanvas().getWidth() -
					aDecKanGlGlyph.getCanvas().getMarginRight() -
					DecKanGlDecoratorCanvasZone.RIGHT_ZONE.getWidth();
		}
		if (this == bottom_zone_LEFT) {
			return (aDecKanGlGlyph.getCanvas().getWidth() / 2) -
					this.getDecoratorWidth();
		}
		if (this == bottom_zone_RIGHT) {
			return (aDecKanGlGlyph.getCanvas().getWidth() / 2) - 1;
		}
		if (this == top_zone_LEFT) {
			return (aDecKanGlGlyph.getCanvas().getWidth() / 2) -
					this.getDecoratorWidth();
		}
		if (this == top_zone_RIGHT) {
			return (aDecKanGlGlyph.getCanvas().getWidth() / 2) - 1;
		}
		return 0;
	}

	public int getCanvasPositionY(DecKanGlGlyph aDecKanGlGlyph) {
		if (this.getCanvasZone() == DecKanGlDecoratorCanvasZone.BOTTOM_ZONE) {
			return aDecKanGlGlyph.getCanvas().getHeight() -
					aDecKanGlGlyph.getCanvas().getMarginBottom() -
					DecKanGlDecoratorCanvasZone.BOTTOM_ZONE.getHeight();
		}
		if (this.getCanvasZone() == DecKanGlDecoratorCanvasZone.TOP_ZONE) {
			return aDecKanGlGlyph.getCanvas().getMarginTop();
		}
		if (this == left_zone_BOTTOM) {
			return aDecKanGlGlyph.getCanvas().getMarginTop() +
					DecKanGlDecoratorCanvasZone.TOP_ZONE.getHeight() +
					DecKanGlDecoratorCanvasLocation.left_zone_TOP.getDecoratorHeight() +
					DecKanGlDecoratorCanvasLocation.left_zone_MIDDLE.getDecoratorHeight() - 2;
		}
		if (this == left_zone_MIDDLE) {
			return aDecKanGlGlyph.getCanvas().getMarginTop() +
					DecKanGlDecoratorCanvasZone.TOP_ZONE.getHeight() +
					DecKanGlDecoratorCanvasLocation.left_zone_TOP.getDecoratorHeight() - 1;
		}
		if (this == left_zone_TOP) {
			return aDecKanGlGlyph.getCanvas().getMarginTop() +
					DecKanGlDecoratorCanvasZone.TOP_ZONE.getHeight();
		}
		if (this == right_zone_BOTTOM) {
			return aDecKanGlGlyph.getCanvas().getMarginTop() +
					DecKanGlDecoratorCanvasZone.TOP_ZONE.getHeight() +
					DecKanGlDecoratorCanvasLocation.left_zone_TOP.getDecoratorHeight() +
					DecKanGlDecoratorCanvasLocation.left_zone_MIDDLE.getDecoratorHeight() - 2;
		}
		if (this == right_zone_MIDDLE) {
			return aDecKanGlGlyph.getCanvas().getMarginTop() +
					DecKanGlDecoratorCanvasZone.TOP_ZONE.getHeight() +
					DecKanGlDecoratorCanvasLocation.left_zone_TOP.getDecoratorHeight() - 1;
		}
		if (this == right_zone_TOP) {
			return aDecKanGlGlyph.getCanvas().getMarginTop() +
					DecKanGlDecoratorCanvasZone.TOP_ZONE.getHeight();
		}
		return 0;
	}
	
}